// MicroIRCd

#include "deps.h"

#define _CRT_SECURE_NO_WARNINGS

#define MAX_CLIENTS 32
#define BUF_SIZE 4096
#define printf _log

typedef struct {
    int sock;
    struct sockaddr_in addr;
    int len;
    char buf[BUF_SIZE];
    int state;
    char nickname[16];
    char username[32];
    char hostname[32];
    char realname[32];
    char servername[32];
    char chanlist[BUF_SIZE];
} client_t;

char *serv = "localhost";
client_t clients[MAX_CLIENTS];
int num_clients;
int str_split(char **arr, char *str, char *d);
int CL_COUNT(char *list);
char *strchr_n(char *str, int n);
char *CL_HEAD(char *list, int n);
char *CL_TAIL(char *list, int n);
char *CL_ITEM(char *list, int n);
int CL_ISSET(char *list, char *key);
int CL_SET(char *list, char *key);
int CL_CLR(char *list, char *key);
int CL_MATCH(char *c1, char *c2);
client_t *get_user_by_nickname(char *nickname);
int get_userlist_by_chan(char *userlist, char *chan);
char *unquote(char *str);
void reply(client_t * cl, char *dest, char *fmt, ...);
int string_to_argv(char **argv, char *str, int size);
int die(int code);
